package com.ktjy.t382.ch01.controller;

import com.ktjy.t382.ch01.entity.SysUser;
import com.ktjy.t382.ch01.entity.SysUsers;
import com.ktjy.t382.ch01.entity.vo.R;
import com.ktjy.t382.ch01.service.SysUserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    SysUserService sysUserService;

    @RequestMapping("/get")
    public SysUser get(@RequestBody SysUser sysUser) {
        return sysUserService.getSysUserByIdService(sysUser);
    }

    @RequestMapping("/adds")
    public R adds(@RequestBody SysUsers sysUsers) {
        try {
            int count = sysUserService.insertSysUsers(sysUsers);
            return R.ok("成功添加" + count + "条数据");
        } catch (Exception e) {
            return R.fail("哈哈出现了异常");
        }
    }

}
